#include <iostream>
#include <stdio.h>
#include <pthread.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#define ERR_EXIT(m)\
do\
{\
    perror(m);\
    exit(EXIT_FAILURE);\
}while(0)

void* pthreadFunc(void * argv){
    sleep(3);
    pthread_detach(pthread_self());
    printf("i am pthread,my errmo is %d\n",errno);
    return NULL;
}


int main(){
    pthread_t tid;
    pthread_create(&tid,NULL,pthreadFunc,NULL);
    sleep(4);
    int err = pthread_cancel(tid);
    // printf("%d\n",errno);
    fprintf(stderr, "pthread_create failed: %s\n", strerror(err));
    return 0; 
}